Spring使用LoadTimeWeaver在类加载到Java虚拟机(JVM)时动态转换类。
想要启用加载时织入,你需要在你的一个@Configuration配置类上添加@EnableLoadTimeWeaving

@Configuration
@EnableLoadTimeWeaving
public class AppConfig {
}

或者,在XML配置中使用context:load-time-weaver元素:

<beans>
    <context:load-time-weaver/>
</beans>

一旦你在ApplicationContext中进行了配置,任何在这个ApplicationContext中的bean都可以通过实现LoadTimeWeaverAware接口来获得load-timer weaver实例的引用。这和[Springs JPA support](https://docs.spring.io/spring/docs/4.3.13.RELEASE/spring-framework-reference/htmlsingle/#orm-jpa)结合起来使用,是十分有用的。JPA类的转换需要在加载时被织入。查阅LocalContainerEntityManagerFactoryBean`的java文档来获取更多信息。如果想要更多的了解AspectJ load-time weaving,请看10.8.4节,"Load-time weaving with AspectJ in the Spring Framework"。